package Model

const (
	API_RESULT_SUCCESS_CODE = iota
	API_RESULT_FAIL_CODE
)

type ApiResult struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

func NewResult() ApiResult {
	return ApiResult{
		Code:    API_RESULT_SUCCESS_CODE,
		Message: "请求成功",
	}
}

func (r *ApiResult) Fail(str string) *ApiResult {
	r.Code = API_RESULT_FAIL_CODE
	r.Message = str
	return r
}
